package cn.com.open.itembank.logic.questiontype;

import cn.com.open.itembank.common.Function;
import cn.com.open.itembank.dto.QuestionImportModel;
import cn.com.open.itembank.dto.QuestionModel;

/**
 * Created by lucky on 2017/12/26.
 */
public class BaseChoiceItem extends QuestionTypeBase {

    /**
     * Instantiates a new Base choice item.
     *
     * @param model the model
     */
    public BaseChoiceItem(QuestionImportModel model) {
        super(model);
        super.mustHasChoice = true;
    }

    //region 获取保存模型

    /**
     * 获取保存模型.
     *
     * @return the input question model
     */
    @Override
    public QuestionModel getSaveModel() {
        QuestionModel model = super.getSaveModel();
        //I6,I7 需要各种题型重载完成
        for (String choice : importModel.getChoices()) {
            model.getI6().add(choice);
        }
        //answer存的是abcd，i7需要0123
        for (String answer : importModel.getAnswer()) {
            model.getI7().add(String.valueOf(Function.getUpperCaseIndex(answer)));
        }

        return model;
    }
    //endregion
}
